﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "GmInplaceEdit.h"
#include "IExternalObject.h"
#include "DbDataSchema.h"

namespace gcmp
{
    class IDocument;
    class IElement;
    class InplaceEditSharedElementInfo;
    class InplaceEditSharedViewContent;

    // 相机构件
    class GM_INPLACE_EDIT_EXPORT InplaceEditProjectReference : public NdbObjectSchematic, public IExternalObject
    {
        CANNOT_COPY_OR_ASSIGN(InplaceEditProjectReference);
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, InplaceEditProjectReference, gcmp::NdbObjectSchematic, DF1B01AF - 18FD - 4D87 - 8572 - 92381B92232A, gminplaceedit, gcmp::IExternalObject)
            DATA_TRANSIENT(IElement*, pOwnerElement)
            MAP_DATA(std::wstring, OwnerPtr<IGraphicsElementShape>, ViewGreps)
        DBOBJECT_DATA_END
    
    public:
        static const InplaceEditProjectReference *Get(IDocument *pDoc, ElementId elementId);
        static InplaceEditProjectReference *GetFw(IDocument *pDoc, ElementId elementId);
        static InplaceEditProjectReference *AddSharedElementInfo(IDocument *pDoc
            , OwnerPtr<InplaceEditSharedElementInfo> opElementInfo, const std::wstring& viewName);
        static bool AddSharedViewContent(IDocument *pDoc, InplaceEditSharedViewContent* pViewContent);

    public:
        IDocument* GetDocument() const;
        ElementId GetOwnerElementId() const;

        const IGraphicsElementShape* GetModelViewGrep(const IModelView* pModelView) const;

#pragma region IExternalObject接口
    public:
        virtual bool SetOwnerElement(IElement* pOwnerElement) override;
        virtual IElement* GetOwnerElement() override { return m_pOwnerElement; }
        virtual const IElement* GetOwnerElement() const override { return m_pOwnerElement; }
        virtual NdbObject* GetTopOwnerObject() const override;

#pragma region 关联更新
        virtual void UpdateForWeakParentDeletion(const std::set<ElementId>& deletedElementIds) override;
        virtual void ReportParents(IElementParentReporter& reporter) const override;
#pragma endregion 关联更新

#pragma region 其他
        virtual bool FinishEditing() override;
#pragma endregion 其他

#pragma endregion IExternalObject接口
    };
}

